package com.minotauro.i18n.base;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.minotauro.i18n.scanner.IsProcessable;

public class I18NIsProcessable implements IsProcessable {

  public static final String I18N_REGEXP = //
  "(I18N|Date|Numb)([a-zA-Z0-9]+)(?:_([a-z]{2})(?:_([A-Z]{2}))?)?.properties";

  public static Pattern p = Pattern.compile(I18N_REGEXP);

  // --------------------------------------------------------------------------------

  public List<String> groupPattern;

  // --------------------------------------------------------------------------------

  @Override
  public Boolean isProcessable(File file, List<String> path) {
    if (matchPattern(p, file.getName())) {
      return true;
    }
    return false;
  }

  // --------------------------------------------------------------------------------

  public boolean matchPattern(Pattern p, String s) {
    groupPattern = new ArrayList<String>();
    Matcher m = p.matcher(s);
    m.find();
    if (m.matches()) {
      for (int i = 0; i < 4; i++) {
        groupPattern.add(m.group(i));
      }
      return true;
    }
    return false;
  }

  // --------------------------------------------------------------------------------

}